$(function() {
	validateRule();

	//打开图标列表
    $("#ico-btn").click(function(){
        layer.open({
            type: 2,
			title:'图标列表',
            content: path.format("/static/FontIcoList.html"),
            area: ['480px', '90%'],
            success: function(layero, index){
                //var body = layer.getChildFrame('.ico-list', index);
                //console.log(layero, index);
            }
        });
    });
	//打开菜单列表
    $("#parentMenuLable").click(function(){
        layer.open({
            type: 2,
			title:'选择父菜单',
            content: path.format("/auth/menu/menuTreePage"),
            area: ['480px', '90%'],
            success: function(layero, index){
            }
        });
    });




});
$.validator.setDefaults({
	submitHandler : function() {
		update();
	}
});
function update() {
	$.ajax({
		cache : true,
		type : "POST",
		url : basePath+"/auth/menu/editMenu",
		data : $('#signupForm').serialize(),// 你的formid
		async : false,
		error : function(request) {
			laryer.alert("Connection error");
		},
		success : function(r) {
		    var data = JSON.parse(r);
			if (data.status == 1000) {
				parent.layer.msg(data.desc,function(){});
				parent.reLoad();
				var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
				parent.layer.close(index);

			} else {
				layer.alert(data.desc)
			}

		}
	});

}
function validateRule() {
	var icon = "<i class='fa fa-times-circle'></i> ";
	$("#signupForm").validate({
        rules : {
            name : {
                required : true
            },
            type : {
                required : true
            },
            permsCode:{
                required : true
            }
        },
        messages : {
            name : {
                required : icon + "请输入菜单名"
            },
            type : {
                required : icon + "请选择菜单类型"
            },
            permsCode : {
                required : icon + "请输入权限标识"
            }
        }
	})
}